home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 April: Mac OS SDK / Dev.CD Apr 96 SDK / Dev.CD Apr 96 SDK1.toast / Development Kits (Disc 1) / OpenDoc Development Framework / ODFDev / ODF / Examples / Movie / Sources / CMovie.cpp next >
Encoding:
Text File  |  1995-11-08  |  24.0 KB  |  846 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                CMovie.cpp
  4. //    Release Version:    $ 1.0d11 $
  5. //
  6. //    Copyright:    © 1993, 1995 by Apple Computer, Inc., all rights reserved.
  7. //
  8. //========================================================================================
  9.  
  10. #ifndef CMOVIE_H
  11. #include "CMovie.h"
  12. #endif
  13.  
  14. // ----- Framework Includes -----
  15.  
  16. #ifndef FWMEMMGR_H
  17. #include "FWMemMgr.h"
  18. #endif
  19.  
  20. #ifndef FWFILESP_H
  21. #include "FWFileSp.h"
  22. #endif
  23.  
  24. #ifndef FWRECT_H
  25. #include "FWRect.h"
  26. #endif
  27.  
  28. #ifndef FWFRAME_H
  29. #include "FWFrame.h"
  30. #endif
  31.  
  32. #ifndef FWEVENT_H
  33. #include "FWEvent.h"
  34. #endif
  35.  
  36. #ifndef FWACQUIR_H
  37. #include "FWAcquir.h"
  38. #endif
  39.  
  40. #ifndef FWMEMHLP_H
  41. #include "FWMemHlp.h"
  42. #endif
  43.  
  44. // ----- OpenDoc Includes -----
  45.  
  46. #ifndef SOM_ODFacet_xh
  47. #include <Facet.xh>
  48. #endif
  49.  
  50. #ifndef SOM_ODWindow_xh
  51. #include <Window.xh>
  52. #endif
  53.  
  54. #ifndef SOM_ODFrame_xh
  55. #include <Frame.xh>
  56. #endif
  57.  
  58. // ----- Platform Includes -----
  59.  
  60. #if defined(FW_BUILD_MAC) && !defined(__GESTALTEQU__)
  61. #include <GestaltEqu.h>
  62. #endif
  63.  
  64. //========================================================================================
  65. //    Runtime informations
  66. //========================================================================================
  67.  
  68. #ifdef FW_BUILD_MAC
  69. #pragma segment odfmovie
  70. #endif
  71.  
  72. //========================================================================================
  73. //    CMovie static methods
  74. //========================================================================================
  75.  
  76. //----------------------------------------------------------------------------------------
  77. //    CMovie::InitializeQuickTime
  78. //----------------------------------------------------------------------------------------
  79.  
  80. FW_Boolean CMovie::InitializeQuickTime()
  81. {
  82.     short error;
  83.     long    result;
  84.  
  85.     error = ::Gestalt(gestaltQuickTime, &result);
  86.     
  87.     if (error == noErr)
  88.     {
  89.         EnterMovies();    //  THROW_IF_ERROR
  90.         return TRUE;
  91.     }
  92.     else
  93.         return FALSE;
  94.     
  95. //    else
  96. //        THROW_IF_ERROR(envNotPresent, "MoviePart:Init:Quicktime not available");
  97. }
  98.  
  99. //----------------------------------------------------------------------------------------
  100. //    CMovie::TerminateQuickTime
  101. //----------------------------------------------------------------------------------------
  102.  
  103. void CMovie::TerminateQuickTime()
  104. {
  105.         ExitMovies();
  106. }
  107.  
  108. //----------------------------------------------------------------------------------------
  109. //    CMovie::NewMovieFromFile
  110. //----------------------------------------------------------------------------------------
  111.  
  112. CMovie* CMovie::CreateNewMovieFromFile(const FW_CFileSpecification& movieFile)
  113. {
  114.     Movie newMovie = NULL;
  115.     short movieResFile;
  116.     short movieResID;
  117.     Str255 movieName;
  118.     FW_Boolean wasChanged;
  119.     FSSpec movieFileSpec;
  120.  
  121.     {
  122.         FW_CMacAcquireMultiFinderHeapZone heapZone;
  123.         
  124.         movieFile.MacGetFSSpec(movieFileSpec);
  125.         OSErr err = ::OpenMovieFile(&movieFileSpec, &movieResFile, fsRdPerm);    // THROW_IF_ERROR
  126.         if (err == noErr)
  127.         {
  128.             movieResID = 0;    // First movie found
  129.             err = ::NewMovieFromFile(&newMovie, movieResFile,
  130.                                         &movieResID,
  131.                                         movieName, newMovieActive,
  132.                                         &wasChanged);    // THROW_IF_ERROR
  133.             ::CloseMovieFile(movieResFile);    // THROW_IF_ERROR
  134.         }
  135.     }
  136.     
  137.     return (newMovie != NULL) ? FW_NEW(CMovie, (newMovie)) : NULL;
  138. }
  139.  
  140. //----------------------------------------------------------------------------------------
  141. //    CMovie::CreateNewMovieFromHandle
  142. //----------------------------------------------------------------------------------------
  143.  
  144. CMovie* CMovie::CreateNewMovieFromHandle(FW_PlatformHandle movieHandle)
  145. {
  146.     Movie newMovie = NULL;
  147.     FW_Boolean dataRefChanged;
  148.     
  149.     if (movieHandle)
  150.     {
  151.         FW_CMacAcquireMultiFinderHeapZone heapZone;
  152.         ::NewMovieFromHandle(&newMovie, movieHandle, newMovieActive, &dataRefChanged);    // THROW_IF_ERROR
  153.     }
  154.     
  155.     return FW_NEW(CMovie, (newMovie));
  156. }
  157.  
  158. //========================================================================================
  159. //    class CMovie
  160. //========================================================================================
  161.  
  162. //----------------------------------------------------------------------------------------
  163. //    CMovie::CMovie
  164. //----------------------------------------------------------------------------------------
  165.  
  166. CMovie::CMovie() :
  167.     fMovie(NULL),
  168.     fMovieController(NULL)
  169. {
  170.     FW_END_CONSTRUCTOR
  171. }
  172.  
  173. //----------------------------------------------------------------------------------------
  174. //    CMovie::CMovie
  175. //----------------------------------------------------------------------------------------
  176.  
  177. CMovie::CMovie(Movie theAdoptedMovie) :
  178.     fMovie(theAdoptedMovie),
  179.     fMovieController(NULL)
  180. {
  181.     FW_SPlatformRect movieBox;
  182.     ::GetMovieBox(fMovie, &movieBox);
  183.         
  184.     {
  185.         FW_CMacAcquireMultiFinderHeapZone heapZone;
  186.         fMovieController = ::NewMovieController(fMovie, &movieBox, mcTopLeftMovie+mcWithBadge+mcNotVisible);
  187.         FW_ASSERT(fMovieController != NULL);
  188.     }
  189.         
  190.     ::MCDoAction(fMovieController, mcActionSetUseBadge, (Ptr)FALSE);
  191.  
  192.     FW_END_CONSTRUCTOR
  193. }
  194.  
  195. //----------------------------------------------------------------------------------------
  196. //    CMovie::CMovie
  197. //----------------------------------------------------------------------------------------
  198.  
  199. CMovie::CMovie(const CMovie& other) :
  200.     fMovie(NULL),
  201.     fMovieController(NULL)
  202. {
  203.     TimeValue currentTime, duration;
  204.     
  205.     other.GetCurrentSelection(¤tTime, &duration);
  206.     ((CMovie&)other).SelectAll();
  207.     fMovie = ((CMovie&)other).CopySelection();
  208.     ((CMovie&)other).SetCurrentSelection(currentTime, duration);
  209.     
  210.     if (fMovie)
  211.     {
  212.         FW_SPlatformRect movieBox;
  213.         ::GetMovieBox(fMovie, &movieBox);
  214.         
  215.         {
  216.             FW_CMacAcquireMultiFinderHeapZone heapZone;
  217.             fMovieController = ::NewMovieController(fMovie, &movieBox, mcTopLeftMovie+mcWithBadge+mcNotVisible);
  218.             FW_ASSERT(fMovieController != NULL);
  219.         }
  220.         
  221.         ::MCDoAction(fMovieController, mcActionSetUseBadge, (Ptr)FALSE);
  222.     }
  223.  
  224.     FW_END_CONSTRUCTOR
  225. }
  226.  
  227. //----------------------------------------------------------------------------------------
  228. // CMovie::operator=
  229. //----------------------------------------------------------------------------------------
  230.  
  231. CMovie& CMovie::operator=(const CMovie& other)
  232. {
  233.     if (this == &other)
  234.         return *this;
  235.         
  236.     if (fMovieController)
  237.     {
  238.         FW_CMacAcquireMultiFinderHeapZone heapZone;
  239.         ::DisposeMovieController(fMovieController);
  240.         fMovieController = NULL;
  241.     }
  242.     
  243.     if (fMovie)
  244.     {
  245.         FW_CMacAcquireMultiFinderHeapZone heapZone;
  246.         ::DisposeMovie(fMovie);
  247.         fMovie = NULL;
  248.     }
  249.         
  250.     FW_Boolean dataRefChanged;
  251.     FW_PlatformHandle movieHandle = FW_CMemoryManager::AllocateSystemHandle(0);
  252.     FW_ASSERT(movieHandle != NULL);
  253.  
  254.     ::PutMovieIntoHandle(other.fMovie, movieHandle); // THROW_IF_ERROR
  255.     {
  256.         FW_CMacAcquireMultiFinderHeapZone heapZone;
  257.         ::NewMovieFromHandle(&fMovie, movieHandle, newMovieActive, &dataRefChanged); // THROW_IF_ERROR
  258.     }
  259.  
  260.     FW_CMemoryManager::FreeSystemHandle(movieHandle);
  261.  
  262.     if (fMovie)
  263.     {
  264.         FW_SPlatformRect movieBox;
  265.         ::GetMovieBox(fMovie, &movieBox);
  266.         
  267.         fMovieController = ::NewMovieController(fMovie, &movieBox, mcTopLeftMovie+mcWithBadge+mcNotVisible);
  268.         FW_ASSERT(fMovieController != NULL);
  269.         
  270.         ::MCDoAction(fMovieController, mcActionSetUseBadge, (Ptr)FALSE);
  271.  
  272.         FW_Boolean enabled;
  273.         
  274.         ::MCDoAction(other.fMovieController, mcActionGetKeysEnabled, &enabled);
  275.         ::MCDoAction(fMovieController, mcActionSetKeysEnabled, (Ptr)enabled);
  276.             
  277.         ::MCDoAction(other.fMovieController, mcActionGetDragEnabled, &enabled);
  278.         ::MCDoAction(fMovieController, mcActionSetDragEnabled, (Ptr)enabled);
  279.  
  280.         ::MCEnableEditing(fMovieController, (::MCIsEditingEnabled(other.fMovieController) != 0));
  281.     }
  282.  
  283.     return *this;
  284. }
  285.  
  286. //----------------------------------------------------------------------------------------
  287. //    CMovie::~CMovie
  288. //----------------------------------------------------------------------------------------
  289.  
  290. CMovie::~CMovie()
  291. {
  292.     FW_START_DESTRUCTOR
  293.  
  294.     FW_CMacAcquireMultiFinderHeapZone heapZone;
  295.  
  296.     if (fMovieController)
  297.     {
  298.         ::DisposeMovieController(fMovieController);
  299.         fMovieController = NULL;
  300.     }
  301.     
  302.     if (fMovie)
  303.     {
  304.         ::DisposeMovie(fMovie);
  305.         fMovie = NULL;
  306.     }
  307. }
  308.  
  309. //----------------------------------------------------------------------------------------
  310. // CMovie::MakeControllerVisible
  311. //----------------------------------------------------------------------------------------
  312.  
  313. void CMovie::MakeControllerVisible(FW_Boolean visible)
  314. {
  315.     if (fMovieController)
  316.         ::MCSetVisible(fMovieController, visible); // THROW_IF_ERROR
  317. }
  318.  
  319. //----------------------------------------------------------------------------------------
  320. // CMovie::GetBoundingBox
  321. //----------------------------------------------------------------------------------------
  322.  
  323. void CMovie::GetBoundingBox(FW_CRect& boundingBox)
  324. {
  325.     FW_SPlatformRect movieBox;
  326.     
  327.     if (fMovieController && ::MCGetVisible(fMovieController))
  328.         ::MCGetControllerBoundsRect(fMovieController, &movieBox);
  329.     else if (fMovie)
  330.         ::GetMovieBox(fMovie, &movieBox);
  331.     
  332.     boundingBox = movieBox;
  333. }
  334.  
  335. //----------------------------------------------------------------------------------------
  336. // CMovie::SetBoundingBox
  337. //----------------------------------------------------------------------------------------
  338.  
  339. void CMovie::SetBoundingBox(const FW_CRect& boundingBox)
  340. {
  341.     FW_SPlatformRect movieBox;
  342.     boundingBox.AsPlatformRect(movieBox);
  343.  
  344.     if (fMovieController && ::MCGetVisible(fMovieController))        
  345.             ComponentResult error = ::MCSetControllerBoundsRect(fMovieController, &movieBox);    // THROW_IF_ERROR
  346.     else if (fMovie)
  347.         ::SetMovieBox(fMovie, &movieBox);
  348. }
  349.  
  350. //----------------------------------------------------------------------------------------
  351. // CMovie::SetGraphicsWorld
  352. //----------------------------------------------------------------------------------------
  353.  
  354. void CMovie::SetGraphicsWorld(ODPlatformWindow platformWindow)
  355. {
  356.     if (fMovie)
  357.         ::SetMovieGWorld(fMovie,(CGrafPtr)platformWindow, NULL);
  358.         
  359.     if (fMovieController)
  360.         ::MCSetControllerPort(fMovieController,(CGrafPtr)platformWindow);
  361. }
  362.  
  363. //----------------------------------------------------------------------------------------
  364. // CMovie::SetClipShape
  365. //----------------------------------------------------------------------------------------
  366.  
  367. void CMovie::SetClipShape(ODRgnHandle clipRegion)
  368. {
  369.     if (fMovieController)
  370.     {            
  371.         FW_CMacAcquireMultiFinderHeapZone heapZone;
  372.  
  373.         FW_SPlatformRect movieBox, controllerBox;
  374.         ::GetMovieBox(fMovie, &movieBox);
  375.         ::MCGetControllerBoundsRect(fMovieController, &controllerBox);
  376.         
  377.         controllerBox.top = movieBox.bottom;
  378.         ODRgnHandle tempRgn = ::NewRgn();
  379.         ::RectRgn(tempRgn, &controllerBox);        // controller region
  380.         
  381.         ::DiffRgn(clipRegion, tempRgn, tempRgn);
  382.         
  383.         ::MCSetClip(fMovieController, clipRegion, tempRgn);    // THROW_IF_ERROR
  384.         
  385.         ::DisposeRgn(tempRgn);
  386.     }
  387. }
  388.  
  389. //----------------------------------------------------------------------------------------
  390. // CMovie::Draw
  391. //----------------------------------------------------------------------------------------
  392.  
  393. void CMovie::Draw(ODPlatformWindow platformWindow)
  394. {
  395.     if (fMovieController)
  396.     {
  397.         FW_CMacAcquireMultiFinderHeapZone heapZone;
  398.         ::MCDraw(fMovieController, platformWindow);
  399.     }
  400. }
  401.  
  402. //----------------------------------------------------------------------------------------
  403. // CMovie::Idle
  404. //----------------------------------------------------------------------------------------
  405.  
  406. void CMovie::Idle()
  407. {
  408.     if (fMovieController)
  409.     {
  410.         FW_CMacAcquireMultiFinderHeapZone heapZone;
  411.         ::MCIdle(fMovieController);
  412.     }
  413. }
  414.  
  415. //---------------------------------------------------------------------------------------
  416. // CMovie::DoMouseDown
  417. //----------------------------------------------------------------------------------------
  418.  
  419. FW_Boolean CMovie::DoMouseDown(Environment* ev, const FW_CMouseEvent& theMouseEvent)
  420. {
  421.     FW_Boolean eventHandled = FALSE;
  422.     
  423.     if (fMovieController)
  424.     {
  425.         ODFacet* facet = theMouseEvent.GetFacet(ev);
  426.         
  427.         FW_CPoint where = theMouseEvent.GetMousePosition(ev, FW_CMouseEvent::kFrame);
  428.         FW_CFrame *frame = FW_CFrame::ODtoFWFrame(ev, facet->GetFrame(ev));
  429.         frame->GetContentView(ev)->FrameToViewContent(ev, where);
  430.         
  431.         FW_SPlatformPoint plfmPoint;
  432.         where.AsPlatformPoint(plfmPoint);
  433.  
  434.         FW_CMacAcquireMultiFinderHeapZone heapZone;
  435.         eventHandled = (FW_Boolean)::MCClick(fMovieController, facet->GetWindow(ev)->GetPlatformWindow(ev),
  436.                                             plfmPoint, theMouseEvent.GetTime(), theMouseEvent.GetModifiers());
  437.     }
  438.     
  439.     return eventHandled;
  440. }
  441.  
  442. //----------------------------------------------------------------------------------------
  443. // CMovie::DoVirtualKeyDown
  444. //----------------------------------------------------------------------------------------
  445.  
  446. FW_Boolean CMovie::DoVirtualKeyDown(Environment* ev, const FW_CVirtualKeyEvent& theVirtualKeyEvent)
  447. {
  448.     FW_Boolean eventHandled = FALSE;
  449.     
  450.     if (fMovieController)
  451.     {
  452.         FW_CMacAcquireMultiFinderHeapZone heapZone;
  453.         eventHandled = (FW_Boolean)::MCKey(fMovieController,
  454.                                                 (char)theVirtualKeyEvent.GetMessage(), theVirtualKeyEvent.GetModifiers());
  455.     }
  456.     
  457.     return eventHandled;
  458. }
  459.  
  460. //----------------------------------------------------------------------------------------
  461. // CMovie::Activate
  462. //----------------------------------------------------------------------------------------
  463. void CMovie::Activate(ODPlatformWindow platformWindow, FW_Boolean activate)
  464. {
  465.     if (fMovieController)
  466.     {
  467.         FW_CMacAcquireMultiFinderHeapZone heapZone;
  468.         ::MCActivate(fMovieController, platformWindow, activate);
  469.     }
  470. }
  471.  
  472. //----------------------------------------------------------------------------------------
  473. // CMovie::Start
  474. //----------------------------------------------------------------------------------------
  475. void CMovie::Start()
  476. {
  477.     if (fMovieController)
  478.     {
  479.         Fixed playRate = ::GetMoviePreferredRate(fMovie);
  480.         FW_CMacAcquireMultiFinderHeapZone heapZone;
  481.         ::MCDoAction(fMovieController, mcActionPlay, (Ptr)playRate);
  482.     }
  483. }
  484.  
  485. //----------------------------------------------------------------------------------------
  486. // CMovie::Stop
  487. //----------------------------------------------------------------------------------------
  488.  
  489. void CMovie::Stop()
  490. {
  491.     if (fMovieController)
  492.     {
  493.         FW_CMacAcquireMultiFinderHeapZone heapZone;
  494.         ::MCDoAction(fMovieController, mcActionPlay, (Ptr)0);
  495.     }
  496. }
  497.  
  498. //----------------------------------------------------------------------------------------
  499. // CMovie::SetLooping
  500. //----------------------------------------------------------------------------------------
  501.  
  502. void CMovie::SetLooping(FW_Boolean loop)
  503. {
  504.     if (fMovieController)
  505.     {
  506.         FW_CMacAcquireMultiFinderHeapZone heapZone;
  507.         ::MCDoAction(fMovieController, mcActionSetLooping, (Ptr)loop);
  508.     }
  509. }
  510.  
  511. //----------------------------------------------------------------------------------------
  512. // CMovie::EnableKeys
  513. //----------------------------------------------------------------------------------------
  514.  
  515. void CMovie::EnableKeys(FW_Boolean enable)
  516. {
  517.     if (fMovieController)
  518.     {
  519.         FW_CMacAcquireMultiFinderHeapZone heapZone;
  520.         ::MCDoAction(fMovieController, mcActionSetKeysEnabled, (Ptr)enable);
  521.     }
  522. }
  523.  
  524. //----------------------------------------------------------------------------------------
  525. // CMovie::EnableEditing
  526. //----------------------------------------------------------------------------------------
  527.  
  528. void CMovie::EnableEditing(FW_Boolean enable)
  529. {
  530.     if (fMovieController)
  531.     {
  532.         FW_CMacAcquireMultiFinderHeapZone heapZone;
  533.         ::MCEnableEditing(fMovieController, enable);
  534.     }
  535. }
  536.  
  537. //----------------------------------------------------------------------------------------
  538. // CMovie::EnableDragging
  539. //----------------------------------------------------------------------------------------
  540.  
  541. void CMovie::EnableDragging(FW_Boolean enable)
  542. {
  543.     if (fMovieController)
  544.     {
  545.         FW_CMacAcquireMultiFinderHeapZone heapZone;
  546.         ::MCDoAction(fMovieController, mcActionSetDragEnabled, (Ptr)enable);
  547.     }
  548. }
  549.  
  550. //----------------------------------------------------------------------------------------
  551. // CMovie::IsLooping
  552. //----------------------------------------------------------------------------------------
  553.  
  554. FW_Boolean CMovie::IsLooping()
  555. {
  556.     FW_Boolean enabled = FALSE;
  557.     
  558.     if (fMovieController)
  559.     {
  560.         FW_CMacAcquireMultiFinderHeapZone heapZone;
  561.         ::MCDoAction(fMovieController, mcActionGetLooping, (Ptr)enabled);
  562.     }
  563.         
  564.     return enabled;
  565. }
  566.  
  567. //----------------------------------------------------------------------------------------
  568. // CMovie::AreKeysEnabled
  569. //----------------------------------------------------------------------------------------
  570.  
  571. FW_Boolean CMovie::AreKeysEnabled()
  572. {
  573.     FW_Boolean enabled = FALSE;
  574.     
  575.     if (fMovieController)
  576.     {
  577.         FW_CMacAcquireMultiFinderHeapZone heapZone;
  578.         ::MCDoAction(fMovieController, mcActionGetKeysEnabled, (Ptr)enabled);
  579.     }
  580.         
  581.     return enabled;
  582. }
  583.  
  584. //----------------------------------------------------------------------------------------
  585. // CMovie::IsEditingEnabled
  586. //----------------------------------------------------------------------------------------
  587.  
  588. FW_Boolean CMovie::IsEditingEnabled()
  589. {
  590.     FW_Boolean enabled = FALSE;
  591.     
  592.     if (fMovieController)
  593.     {
  594.         FW_CMacAcquireMultiFinderHeapZone heapZone;
  595.         enabled = ::MCIsEditingEnabled(fMovieController) != 0;
  596.     }
  597.         
  598.     return enabled;
  599. }
  600.  
  601. //----------------------------------------------------------------------------------------
  602. // CMovie::IsDragEnabled
  603. //----------------------------------------------------------------------------------------
  604.  
  605. FW_Boolean CMovie::IsDragEnabled()
  606. {
  607.     FW_Boolean enabled = FALSE;
  608.     
  609.     if (fMovieController)
  610.     {
  611.         FW_CMacAcquireMultiFinderHeapZone heapZone;
  612.         ::MCDoAction(fMovieController, mcActionGetDragEnabled, (Ptr)enabled);
  613.     }
  614.         
  615.     return enabled;
  616. }
  617.  
  618. //----------------------------------------------------------------------------------------
  619. // CMovie::IsPlaying
  620. //----------------------------------------------------------------------------------------
  621.  
  622. FW_Boolean CMovie::IsPlaying()
  623. {
  624.     FW_Boolean playing = FALSE;
  625.     Fixed playRate;
  626.     
  627.     if (fMovieController)
  628.     {
  629.         FW_CMacAcquireMultiFinderHeapZone heapZone;
  630.         ::MCDoAction(fMovieController, mcActionGetPlayRate, &playRate);
  631.         playing = playRate != 0;
  632.     }
  633.         
  634.     return playing;
  635. }
  636.  
  637. //------------------------------------------------------------------------------
  638. // CMovie::GetCurrentSelection
  639. //------------------------------------------------------------------------------
  640.  
  641. void CMovie::GetCurrentSelection(TimeValue* currentTime, TimeValue* duration) const
  642. {
  643.     if (fMovie)
  644.     {
  645.         FW_CMacAcquireMultiFinderHeapZone heapZone;
  646.         ::GetMovieSelection(fMovie, currentTime, duration);
  647.     }
  648. }
  649.  
  650. //------------------------------------------------------------------------------
  651. // CMovie::SetCurrentSelection
  652. //------------------------------------------------------------------------------
  653.  
  654. void CMovie::SetCurrentSelection(TimeValue currentTime, TimeValue duration)
  655. {
  656.     if (fMovie)
  657.     {
  658.         FW_CMacAcquireMultiFinderHeapZone heapZone;
  659.         ::SetMovieSelection(fMovie, currentTime, duration);
  660.         ::MCMovieChanged(fMovieController, fMovie);    // THROW_IF_ERROR
  661.     }
  662. }
  663.  
  664. //------------------------------------------------------------------------------
  665. // CMovie::ClearCurrentSelection
  666. //------------------------------------------------------------------------------
  667.  
  668. void CMovie::ClearCurrentSelection()
  669. {
  670.     if (fMovieController)
  671.     {
  672.         FW_CMacAcquireMultiFinderHeapZone heapZone;
  673.         ::MCClear(fMovieController);    // THROW_IF_ERROR
  674.     }
  675. }
  676.  
  677. //------------------------------------------------------------------------------
  678. // CMovie::ClearSelection
  679. //------------------------------------------------------------------------------
  680.  
  681. void CMovie::ClearSelection(TimeValue currentTime, TimeValue duration)
  682. {
  683.     if (fMovieController)
  684.     {
  685.         FW_CMacAcquireMultiFinderHeapZone heapZone;
  686.         this->SetCurrentSelection(currentTime, duration);
  687.         ::MCClear(fMovieController);    // THROW_IF_ERROR
  688.     }
  689. }
  690.  
  691. //----------------------------------------------------------------------------------------
  692. // CMovie::CloseSelection
  693. //----------------------------------------------------------------------------------------
  694.  
  695. void CMovie::CloseSelection()
  696. {
  697.     this->SetCurrentSelection(0, 0);
  698. }
  699.  
  700. //------------------------------------------------------------------------------
  701. // CMovie::IsSelectionEmpty
  702. //------------------------------------------------------------------------------
  703. FW_Boolean CMovie::IsSelectionEmpty()
  704. {
  705.     FW_Boolean empty = TRUE;
  706.     
  707.     if (fMovie)
  708.     {
  709.         TimeValue currentTime, duration;
  710.         this->GetCurrentSelection(¤tTime, &duration);
  711.         empty = duration == (TimeValue)0;
  712.     }
  713.     return empty;
  714. }
  715.  
  716. //------------------------------------------------------------------------------
  717. // CMovie::SelectAll
  718. //------------------------------------------------------------------------------
  719. void CMovie::SelectAll()
  720. {
  721.     this->SetCurrentSelection((TimeValue)0, ::GetMovieDuration(fMovie));
  722. }
  723.  
  724. //------------------------------------------------------------------------------
  725. // CMovie::CopySelection
  726. //------------------------------------------------------------------------------
  727. Movie CMovie::CopySelection()
  728. {
  729.     if (fMovieController)
  730.     {
  731.         FW_CMacAcquireMultiFinderHeapZone heapZone;
  732.         return ::MCCopy(fMovieController);
  733.     }
  734.     else
  735.         return NULL;
  736. }
  737.  
  738. //------------------------------------------------------------------------------
  739. // CMovie::CopyCurrentSelectionToHandle
  740. //------------------------------------------------------------------------------
  741. FW_PlatformHandle CMovie::CopyCurrentSelectionToHandle()
  742. {
  743.     FW_PlatformHandle movieHandle = NULL;
  744.     if (fMovieController)
  745.     {
  746.         Movie newMovie;
  747.         {
  748.             FW_CMacAcquireMultiFinderHeapZone heapZone;
  749.             newMovie = ::MCCopy(fMovieController);
  750.         }
  751.         
  752.         movieHandle = ::FW_CMemoryManager::AllocateSystemHandle(0);
  753.         FW_ASSERT(movieHandle != NULL);
  754.         
  755.         ::PutMovieIntoHandle(newMovie, movieHandle);    // THROW_IF_ERROR
  756.         
  757.         {
  758.             FW_CMacAcquireMultiFinderHeapZone heapZone;
  759.             ::DisposeMovie(newMovie);
  760.         }
  761.     }
  762.     return movieHandle;
  763. }
  764.  
  765. //------------------------------------------------------------------------------
  766. // CMovie::GetAsHandle
  767. //------------------------------------------------------------------------------
  768. FW_PlatformHandle CMovie::GetAsHandle()
  769. {
  770.     FW_PlatformHandle movieHandle = NULL;
  771.     
  772.     if (fMovie)
  773.     {
  774.         movieHandle = FW_CMemoryManager::AllocateSystemHandle(0);    // THROW_IF_NULL
  775.         FW_ASSERT(movieHandle != NULL);
  776.         ::PutMovieIntoHandle(fMovie, movieHandle);    // THROW_IF_ERROR
  777.     }
  778.         
  779.     return movieHandle;
  780. }
  781.  
  782. //------------------------------------------------------------------------------
  783. // CMovie::GetAsPict
  784. //------------------------------------------------------------------------------
  785. FW_PlatformPict CMovie::GetAsPict()
  786. {
  787.     FW_PlatformPict moviePict = NULL;
  788.     if (fMovie)
  789.         moviePict = ::GetMoviePict(fMovie, ::GetMovieTime(fMovie, NULL));
  790.     return moviePict;
  791. }
  792.  
  793. //----------------------------------------------------------------------------------------
  794. // CMovie::PasteMovieToSelection
  795. //----------------------------------------------------------------------------------------
  796. void CMovie::PasteMovieToSelection(CMovie* newMovie, TimeValue currentTime, TimeValue duration)
  797. {
  798.     if (fMovieController)
  799.     {
  800.         this->SetCurrentSelection(currentTime, duration);
  801.         this->PasteMovieToCurrentSelection(newMovie);
  802.     }
  803. }
  804.  
  805. //----------------------------------------------------------------------------------------
  806. // CMovie::PasteMovieToCurrentSelection
  807. //----------------------------------------------------------------------------------------
  808. void CMovie::PasteMovieToCurrentSelection(CMovie* newMovie)
  809. {
  810.     if (fMovieController)
  811.     {
  812.         FW_CMacAcquireMultiFinderHeapZone heapZone;
  813.         ::AddMovieSelection(fMovie, *newMovie);
  814.         ::MCMovieChanged(fMovieController, fMovie);
  815. //        ::MCPaste(fMovieController, *newMovie);    // THROW_IF_ERROR
  816.     }
  817. }
  818.  
  819. //----------------------------------------------------------------------------------------
  820. // CMovie::PasteHandleToSelection
  821. //----------------------------------------------------------------------------------------
  822. void CMovie::PasteHandleToSelection(FW_PlatformHandle newHandle, OSType handleType, TimeValue currentTime, TimeValue duration)
  823. {
  824.     if (fMovie)
  825.     {
  826.         FW_CMacAcquireMultiFinderHeapZone heapZone;
  827.         this->SetCurrentSelection(currentTime, duration);
  828.         ::PasteHandleIntoMovie(newHandle, handleType, fMovie, 0, (ComponentInstance)0);    // THROW_IF_ERROR
  829.         ::MCMovieChanged(fMovieController, fMovie);    // THROW_IF_ERROR
  830.     }
  831. }
  832.  
  833. //----------------------------------------------------------------------------------------
  834. // CMovie::PasteHandleToCurrentSelection
  835. //----------------------------------------------------------------------------------------
  836. void CMovie::PasteHandleToCurrentSelection(FW_PlatformHandle newHandle, OSType handleType)
  837. {
  838.     if (fMovie)
  839.     {
  840.         FW_CMacAcquireMultiFinderHeapZone heapZone;
  841.         ::PasteHandleIntoMovie(newHandle, handleType, fMovie, 0, (ComponentInstance)0);    // THROW_IF_ERROR
  842.         ::MCMovieChanged(fMovieController, fMovie);    // THROW_IF_ERROR
  843.     }
  844. }
  845.  
  846.